import http from '@/utils/http.js';

// 修正：后端路径是 /apis/shopApi/getAllShops，前端直接拼接baseURL（无需重复写localhost:8080）
export const getAllShops = () => {
    return http({
        url: '/api/shopApi/getAllShops', // 与后端完全一致：/apis/shopApi/getAllShops
        method: 'get',
        params: {}
    });
};

// 新增：查询「某商铺下的商品」接口（核心：调用后端已有的selectShopGoodsByShopId方法）
export const getShopGoods = (shopId) => {
    return http({
        url: '/api/shopApi/getShopGoods', // 后续后端要新增这个商品查询接口
        method: 'get',
        params: { shopId } // 传商铺ID，查询该商铺下的商品
    });
};

// 新增：根据ID查询商铺详情
export const getShopById = (shopId) => {
    return http({
        url: `/api/shopApi/${shopId}`,
        method: 'get'
    });
};

// 新增：获取店铺统计数据
export const getShopStatistics = (shopId) => {
    return http({
        url: `/api/shopApi/statistics/${shopId}`,
        method: 'get'
    });
};

// 新增：获取店铺商品销量排行
export const getShopSalesRanking = (shopId) => {
    return http({
        url: `/api/shopApi/statistics/sales-ranking/${shopId}`,
        method: 'get'
    });
};

// 新增：获取店铺收入趋势
export const getShopRevenueTrend = (shopId) => {
    return http({
        url: `/api/shopApi/statistics/revenue-trend/${shopId}`,
        method: 'get'
    });
};

// 新增：获取店铺订单状态统计
export const getShopOrderStatusStats = (shopId) => {
    return http({
        url: `/api/shopApi/statistics/order-status/${shopId}`,
        method: 'get'
    });
};